cd /d "%~dp0"
powershell -c "set-executionpolicy unrestricted"
for /f %%p in ('powershell .\getLocalResource.ps1 Node') do set NODEPATH=%%p

7za x node-0.4.7-cygwin.7z -y -o"%NODEPATH%"
REM strip off top level directory (like "node-0.4.7-cygwin")
for /d %%d in ("%NODEPATH%\node-0.4.7-cygwin\*") do move "%%d" "%NODEPATH%"

powershell .\makeResolvConf.ps1 > "%NODEPATH%\etc\resolv.conf"

for /f %%p in ('powershell .\getLocalResource.ps1 Git') do set GITPATH=%%p

call "%NODEPATH%\bin\setenv"

REM Otherwise things seem to go to /cygdrive/c/bin and /cygdrive/c/lib
node /usr/bin/npm config set prefix /usr

REM Not strictly necessary, but I'm going to always compile *.coffee from the src/ directory
node /usr/bin/npm install coffee-script -g --verbose

echo y| cacls "%NODEPATH%" /grant everyone:f /t

exit /b 0